package fan.project1_SpeedTalkSystem.Service;

import fan.project1_SpeedTalkSystem.Mapper.BlogMapper;
import fan.project1_SpeedTalkSystem.Model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogMapper blogMapper;

    public List<BlogInfo> getBlogList() {
        return blogMapper.selectAllBlogInfo();
    }

    public BlogInfo getBlogListById(Integer id) {
        return blogMapper.selectBlogInfoByid(id);
    }

    public Integer getUserIdByBlogId(int blogId) {
        return blogMapper.getUserIdByBlogId(blogId);
    }

    public boolean insertBlog(BlogInfo blogInfo) {
        return blogMapper.inserBlogInfo(blogInfo)==1;
    }

    public boolean updateBlogById(BlogInfo blogInfo) {
        return blogMapper.updateBlogByid(blogInfo)==1;
    }

    public boolean deleteBlogByid(Integer id) {
        return blogMapper.deleteBlogByid(id)==1;
    }
}
